// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import 'babel-polyfill'
import Vue from 'vue'
import App from './App'
import store from '@/vuex/index'
import router from './router'
import { sync } from 'vuex-router-sync'
import {Progress, DatePicker, Submenu, Loading, Pagination, Menu, MenuItem, Col, Dialog, Form, FormItem, Select, Option, Input, Button, Tooltip, Row, Checkbox, Message, Upload, Table, TableColumn} from 'element-ui'
import '@/styles/common/reset.css';
import '@/styles/common/index.scss';
Vue.use(Progress)
Vue.use(Menu)
Vue.use(MenuItem)
Vue.use(Col)
Vue.use(Dialog)
Vue.use(Form)
Vue.use(FormItem)
Vue.use(Select)
Vue.use(Option)
Vue.use(Input)
Vue.use(Button)
Vue.use(Tooltip)
Vue.use(Row)
Vue.use(Upload)
Vue.use(Checkbox)
Vue.use(Table)
Vue.use(Loading)
Vue.use(Pagination)
Vue.use(TableColumn)
Vue.use(Submenu)
Vue.use(DatePicker)
Vue.prototype.$message = Message
Vue.config.productionTip = false

// 添加路由对象到 store 中
sync(store, router);
// 注册AppStatus
store.registerModule('appStatus', {
  state: {
    sidebar: false,
    isLoading: false,
    sidebarData: []
  },

  mutations: {
    updateSidebarStatus (state, status) {
      state.sidebar = status
    },

    updateLoadingStatus (state, status) {
      state.isLoading = status
    },

    updateSidebarData (state, date) {
      state.sidebarData = date
    }
  },

  actions: {
    updateSidebarStatus ({ commit }, status) {
      commit('updateSidebarStatus', status)
    },
    updateSideber ({ commit }, data) {
      commit('updateSidebarData', data)
    }
  }
})

/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  store,
  template: '<App/>',
  components: { App }
})
